package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.mapper.IEmployeeMapper;
import com.project.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class EmployeeServiceImpl implements IEmployeeService {
    public int PAGESIZE = 3;
    @Autowired
    private IEmployeeMapper mapper;

    @Override
    public PageInfo<EmployeeBean> findByItem(int pageNO, String name, String skill, String state, String sort) {
        PageHelper.startPage(pageNO,PAGESIZE);
        PageInfo<EmployeeBean> pageInfo = PageInfo.of(mapper.findByItem(name,skill,state,sort));
        return pageInfo;
    }

    @Override
    public void add(EmployeeBean employee) {
        mapper.add(employee);
    }

    @Override
    public void del(int id) {
        mapper.del(id);
    }

    @Override
    public void update(int id, String tel, int salary) {
        mapper.update(id,tel,salary);
    }

    @Override
    public EmployeeBean findById(int id) {
        EmployeeBean employee = mapper.findById(id);
        return employee;
    }

    @Override
    public List<EmployeeBean> findNotInProject(int projectId, String name, String skill) {
        List<EmployeeBean> list = mapper.findNotInProject(projectId,name,skill);
        return list;
    }
}
